package com.example.woke;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.widget.Toast;

import com.woke.method.MyApp;
import com.zhongcai.online.R;

import java.util.ArrayList;

public class JiebangActivity extends Activity {

	private Intent intent;
	private ArrayList<String> list;
	private MyApp application;
	private int intExtra;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_jiebang);
		
		intent = getIntent();
		list = intent.getStringArrayListExtra("no");
		intExtra = intent.getIntExtra("currentno", 0);
		intview();
		
	}
	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		// TODO Auto-generated method stub
		super.onActivityResult(requestCode, resultCode, data);
		
		if(requestCode == 10 && resultCode == 11){
			intent.putExtra("currentno", intExtra);//���صڼ���
			setResult(resultCode, intent);
			finish();
		}
		
	}
	

	private void intview() {
		
		application = (MyApp) getApplication();
		
		TextView mTbank = (TextView) findViewById(R.id.avjiebang_text_bank);
		TextView mTtype = (TextView) findViewById(R.id.avjiebang_text_type);
		TextView mTcarno = (TextView) findViewById(R.id.avjiebang_text_carno);
		
		mTbank.setText(list.get(4));
		if(list.get(5).equals("1")){
			mTtype.setText("储蓄卡");
		}else{
			mTtype.setText("信用卡");
		}
		mTcarno.setText(list.get(3)); //银行卡 卡号
		
		findViewById(R.id.avjiebang_image_back).setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();
			}
		});
		
		findViewById(R.id.avjiebang_text_ok).setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				if(application.getDatas_load ()==null)return;
				if(null == application.getDatas_load().getPay_pwd() || application.getDatas_load().getPay_pwd().equals("")){
					Toast.makeText(JiebangActivity.this, "请先设置支付密码", Toast.LENGTH_SHORT).show();
					intent.setClass(JiebangActivity.this, PswchangeActivity.class);
					intent.putExtra("name", 0);
					startActivity(intent);
				}else{
					intent.setClass(JiebangActivity.this, JiebangcarActivity.class);
					intent.putExtra("carno", list.get(3));
					startActivityForResult(intent, 10);
				}
			}
		});
		
	}
}
